/**
 * 
 */
package de.cbf.cam.dsa.battle.ui.listeners;

import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;

/**
 * @author Nebelritter
 *
 */
public class EnterNumbers implements VerifyListener {
	private static EnterNumbers instance = new EnterNumbers();
	
	/**
	 * @uml.property  name="checkString"
	 */
	private String checkString ="-0123456789\b\r";
	/**
	 * 
	 */
	public EnterNumbers() {		
	}

	@Override
	public void verifyText(VerifyEvent e) {	
		//test character wise
		for(int i=0;i<e.text.length();i++){
			char character =e.text.charAt(i);
			String test =character+"";
			if(!checkString.contains(test)){
				e.doit =false;				
			}
		}		
	}			 
	
	/**
	 * @return
	 * @uml.property  name="checkString"
	 */
	public String getCheckString(){
		return checkString;
	}

	public static EnterNumbers getInstance(){		
		return instance;
	}
	public static EnterNumbers getInstance(String newCheckString){
		EnterNumbers instance = new EnterNumbers();
		instance.checkString = newCheckString;
		return instance;
	}
	
}
